package gui;

import gui.AbstractViewPane.ViewMode;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.SpringLayout;

public class PanelCongeUIConsulter extends JFrame implements ActionListener {
	String debut = "JJ/MM/AAAA";
	String fin = "JJ/MM/AAAA";
	ViewMode currentViewMode;
	JPanel general;
    JButton save;
    JButton annuler;

	
	public void drawCommandBox(JPanel commandBox) {
        JPanel buttonPanel = new JPanel(new BorderLayout());
        buttonPanel.add(new JSeparator(), BorderLayout.PAGE_START);
        buttonPanel.add(commandBox, BorderLayout.LINE_END);
        
        general.add(buttonPanel, BorderLayout.SOUTH);
	}
	
	public PanelCongeUIConsulter(ViewMode v) {
		
		currentViewMode = v;
		
    	setSize(500, 300);
		setTitle("Gestion des congés");
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		
		general = new JPanel();
		general.setLayout(new BorderLayout());
		
		general.setBorder(BorderFactory.createCompoundBorder(
		BorderFactory.createTitledBorder(getTitle()),
		BorderFactory.createEmptyBorder(5,5,5,5)));

				
        //Create and populate the panel.
        JPanel p = new JPanel(new SpringLayout());
        
        JLabel l = new JLabel("Début Congé:", JLabel.TRAILING);
        p.add(l);
        JTextField text = new JTextField (debut);
        l.setLabelFor(text);
        p.add(text);
        
        l = new JLabel("Fin Congé:", JLabel.TRAILING);
        p.add(l);
        text = new JTextField (fin);
        l.setLabelFor(text);
        p.add(text);

        //Lay out the panel.
        SpringUtilities.makeCompactGrid(p,
                                        2, 2, //rows, cols
                                        6, 6,        //initX, initY
                                        6, 6);       //xPad, yPad
        
        general.add(p, BorderLayout.NORTH);
        add(general);
        
    	// Mode modification - afficher les boutons
        JPanel commandBox = new JPanel();
        save = new JButton("Enregistrer");
        save.addActionListener(this);
        commandBox.add(save);
        annuler = new JButton("Annuler");
        annuler.addActionListener(this);
        commandBox.add(annuler);
        drawCommandBox(commandBox);
        

	}

	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		if (e.getSource() == save) {
			System.out.println("Enregistrer");
		}
		if (e.getSource() == annuler) {
			this.dispose();
		}
		
	}
}
